/*
 * @Descripttion:
 * @version:
 * @Author: kl2018
 * @Date: 2019-03-07 20:06:20
 * @LastEditors: kl2018
 * @LastEditTime: 2020-08-18 14:03:13
 */
import { observable, action } from 'mobx';
import { WeaTableNew } from 'comsMobx';
import * as API_REPORT from '../../apis/reportApi';
import * as ODOC_LABEL from '../../constants/label';

const { TableStore } = WeaTableNew;

/**
 * 公文报表对话框  数据对象
 */
export default class ReportDocEchartDetailListDialogStore {
  @observable visable = false;

  @observable condition_base = {};
  @observable condition_name = '';
  @observable condition_analyseType = '';


  @observable tableStore = new TableStore();

  constructor() {
    this.doSearch = this.doSearch.bind(this);
  }


  @action
  setCondition_base = (condition_base) => {
    this.condition_base = condition_base;
  }

  setSearchsBaseValue(v) {
    this.condition_name = v;
  }

  doSearch = (params = {}) => {
    API_REPORT.getOdocDocReportEchartDetailList(params).then((data) => {
      this.tableStore.getDatas(data.sessionkey, params.current || 1);
    });
    return this;
  }

  getDialogTitleName() {
    if (this.condition_analyseType == 1) {
      return ODOC_LABEL.NAME.ODOC_TYPE_TOP;
    } else if (this.condition_analyseType == 2) {
      return ODOC_LABEL.NAME.ODOC_TOPIC_TOP;
    } else if (this.condition_analyseType == 4) {
      return ODOC_LABEL.NAME.ODOC_DEPARTMENT_TOP;
    } else if (this.condition_analyseType == 5) {
      return ODOC_LABEL.NAME.ODOC_SUBCOMPANY_TOP;
    }
  }

  showDialog(analyseType) {
    this.condition_analyseType = analyseType;
    this.visable = true;
  }

  hideDialog = () => {
    this.visable = false;
    this.condition_name = '';
  }
}
